#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5;
typedef long long LL;

int main(void)
{
    LL n, a, b, c;
    cin >> n >> a >> b >> c;
    LL res = -1;
    for (LL i = 0; i <= n / a; i++)
        for (LL j = 0; i * a + j * b <= n; j++)
        {
            if ((n - a * i - b * j) % c == 0)
            {
                res = max(res, (i + j + (n - (a * i) - (b * j)) / c));
            }
        }
    cout << res << endl;
    return 0;
}